import type { User, CodeType, UserInfo, Patient } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginByPassword = (mobile: string, password: string) => 
  request<User>('/login/password', 'POST', { mobile, password })

// 发送验证码
export const sendMobileCode = (mobile: string, type: CodeType) => 
  request('/code', 'GET', { mobile, type })

// 短信登录
export const loginByMobile = (mobile: string, code: string) =>
  request<User>('/login', 'POST', { mobile, code })

// 我的-获取用户信息
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

// 获取患者列表
export const getPatientList = () => request<Patient[]>('patient/mylist')

// 问诊-添加用户信息
export const addPatient = (payload: Patient) => request('patient/add', 'POST', payload)

// 问诊-删除用户信息
export const updatePatient = (payload: Patient) => request('/patient/update', 'PUT', payload)

// 问诊-删除用户信息
export const delPatient = (id: string) => request(`/patient/del/${id}`, 'DELETE')

// 问诊-查询用户详情
export const getPatientDetail = (id: string) => request<Patient>(`/patient/info/${id}`)